package edu.pku.sei.modeler.uml.commands.sequence;

import org.eclipse.gef.commands.Command;
import edu.pku.sei.modeler.model.structure.MetaLink;

public class SequenceReconnectSourceCommand extends Command {
	MetaLink link = null;
	int oldOffset = 0;
	int newOffset = 0;
	
	public SequenceReconnectSourceCommand(MetaLink link, int newOffset) {
		this.link = link;
		this.oldOffset = link.getOffset();
		this.newOffset = newOffset;
	}
	
	public boolean canExecute() {
		if (link != null)
			return true;
		else
			return false;
	}
	
	public void execute() {
		link.setOffset(newOffset);
	}
	
	public boolean canUndo() {
		if (link != null)
			return true;
		else
			return false;
	}
	
	public void undo() {
		link.setOffset(oldOffset);
	}
}
